# -*- coding: utf-8 -*-
"""
Created on Tue Feb 27 15:15:30 2024

@author: lishengpeng
"""
import tkinter as tk
from tkinter import filedialog

def open_file_dialog():
    root = tk.Tk()  # 创建一个临时的Tk窗口，用于显示文件对话框
    root.withdraw()  # 隐藏主窗口，仅显示文件对话框

    # 打开文件对话框，设置默认行为为多选
    file_paths = filedialog.askopenfilenames(
        parent=root,
        title="选择文件",
        initialdir="/",  # 设置初始目录
        filetypes=(("All Files", "*.*"), ("Text Files", "*.txt"))  # 设置文件类型过滤器
    )

    path_list = []
    print("你选择了以下文件：")
    for path in file_paths:
        path_list.append(path)

    root.destroy()  # 关闭临时窗口
    return path_list

file_paths = open_file_dialog()

print(file_paths)

